import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 购物车数量
    num: 0,
    // 商品详情
    goodsDetail: []
  },
  mutations: {
    initList(state, list) {
      state.goodsDetail = list
    },
    // 购物车数量发生了变化
    changeNum: function(state, newNum) {
      state.num += newNum
    },
    changeNum2(state, n) {
      state.num = n
    }
  },
  actions: {},
  modules: {}

})
